5/27/2021

Instructions

Create a web page presentation using R Markdown that features a plot created with Plotly. Host your webpage on either GitHub Pages, RPubs, or NeoCities. Your webpage must contain the date that you created the document, and it must contain a plot created with Plotly. We would love to see you show off your creativity!

The rubric contains the following two questions:

  1. Does the web page feature a date and is this date less than two months before the date that you’re grading this assignment?
  2. Is the web page a presentation and does it feature an interactive plot that appears to have been created with Plotly?

Load and Prepare Data

library(plotly)
data <- diamonds[sample(nrow(diamonds), 2000), 
                 c("carat", "price", "clarity", "depth")]
summary(data)
     carat            price            clarity        depth      
 Min.   :0.2300   Min.   :  358.0   SI1    :476   Min.   :55.30  
 1st Qu.:0.3900   1st Qu.:  897.2   VS2    :463   1st Qu.:61.10  
 Median :0.7000   Median : 2318.5   SI2    :334   Median :61.80  
 Mean   :0.7896   Mean   : 3859.7   VS1    :303   Mean   :61.76  
 3rd Qu.:1.0400   3rd Qu.: 5397.8   VVS2   :201   3rd Qu.:62.50  
 Max.   :4.0000   Max.   :18791.0   VVS1   :137   Max.   :72.20  
                                    (Other): 86                  

Create 2D and 3D Scatter Plots

p1 <- plot_ly(data, x = ~carat, y = ~price, color = ~carat,
        size = ~carat, text = ~paste("Clarity: ", clarity))
p2 <- plot_ly(data, x = ~carat, y = ~price, z = ~depth,
        color = ~carat, size = ~carat, 
        text = ~paste("Clarity: ", clarity)) 

Show 2D Scatter Plot

Show 3D Scatter Plot